package com.asia5b.a5mall.order.adapter

import android.graphics.Typeface
import androidx.core.content.ContextCompat
import android.widget.TextView
import com.asia5b.a5mall.middleware.model.bean.OrderDetailPriceBean
import com.asia5b.a5mall.order.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2020/5/11.
 */
class OrderDetailPriceAdapter(list: ArrayList<OrderDetailPriceBean>) :
        BaseQuickAdapter<OrderDetailPriceBean, BaseViewHolder>(R.layout.item_orderdetailprice_copy, list) {
    init {
        addChildClickViewIds(R.id.tv_orderdetailprice_copy)
    }
    override fun convert(helper: BaseViewHolder, item: OrderDetailPriceBean) {
        helper.setText(R.id.tv_orderdetailprice_name, item.name)
        helper.setText(R.id.tv_orderdetailprice_value, item.value)
        helper.setGone(R.id.tv_orderdetailprice_copy, true)
        val tv_orderdetailprice_name = helper.getView<TextView>(R.id.tv_orderdetailprice_name)
        val tv_orderdetailprice_value = helper.getView<TextView>(R.id.tv_orderdetailprice_value)
        when (item.type) {
            //一般的item
            OrderDetailPriceBean.item_normal -> {

            }
            //复制
            OrderDetailPriceBean.item_copy -> {
                helper.setGone(R.id.tv_orderdetailprice_copy, false)

            }
            //商品总价
            OrderDetailPriceBean.item_goods_price -> {//价格显示红色
                tv_orderdetailprice_value.setTextColor(ContextCompat.getColor(context,R.color.color_red))
            }
            //国际运费
            OrderDetailPriceBean.item_international_price -> {//价格显示红色
                tv_orderdetailprice_value.setTextColor(ContextCompat.getColor(context,R.color.color_red))
            }
            //优惠券折扣
            OrderDetailPriceBean.item_coupon_price -> {//价格显示红色
                tv_orderdetailprice_value.setTextColor(ContextCompat.getColor(context,R.color.color_red))
                tv_orderdetailprice_value.setText("-${item.value}")
            }
            //订单总价
            OrderDetailPriceBean.item_order_price -> {//价格显示红色
                tv_orderdetailprice_value.setTextColor(ContextCompat.getColor(context,R.color.color_red))
            }
            //实际付款
            OrderDetailPriceBean.item_totalprice -> {
                tv_orderdetailprice_name.setTextSize(16f)
                tv_orderdetailprice_name.setTypeface(Typeface.DEFAULT_BOLD)
                tv_orderdetailprice_value.setTextSize(16f)
                tv_orderdetailprice_value.setTypeface(Typeface.DEFAULT_BOLD)
            }
        }
    }
}